

#!/usr/bin/env bash
set -euo pipefail

COMPOSE_FILE="docker-compose.yml"   # 如有需要请改路径
SERVICE="iot-service"

echo ">>> 1/3 强制重建镜像"
docker compose -f "$COMPOSE_FILE" build --no-cache "$SERVICE"

echo ">>> 2/3 停止并删除旧容器"
docker compose -f "$COMPOSE_FILE" rm -fsv "$SERVICE"

echo ">>> 3/3 重新创建并启动容器"
docker compose -f "$COMPOSE_FILE" up -d "$SERVICE"

echo ">>> 完成！容器已使用全新镜像启动。执行下面命令查看日志"

echo ">>> docker compose logs --tail 20 -f "
